<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateSystemInformationTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('system_information', function (Blueprint $table) {
            $table->bigIncrements('id')->unsigned();
            $table->float('cpu_usage_rate')->comment('CPU使用率, 百比分12.34');
            $table->float('memory_usage')->comment('内存使用量,单位G');
            $table->float('memory_total')->comment('内存总量,单位G');
            $table->float('disk_usage')->comment('磁盘使用量,单位G');
            $table->float('disk_total')->comment('磁盘总量,单位G');
            $table->unsignedInteger('active_conn')->comment('活跃连接数');
            $table->unsignedInteger('mysql_conn')->comment('MySQL连接数');
            $table->unsignedInteger('mysql_conn_total')->comment('MySQL连接池上限');
            $table->float('redis_memory_usage')->comment('redis内存使用量');
            $table->float('redis_memory_total')->comment('redis内存分配量');
            $table->unsignedSmallInteger('mysql_qps')->comment('MySQL每秒查询次数');
            $table->unsignedInteger('active_users')->comment('活跃用户数');
            $table->unsignedInteger('app_rps')->comment('应用每秒请求数');
            $table->float('error_rate')->comment('错误率');

            $table->timestamp('created_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('system_information');
    }
}
